package com.planet.classes;

import java.util.ArrayList;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class HighlightHandler extends DefaultHandler {
	private ArrayList<Integer> _highlights;
	private String _current;
	
	public HighlightHandler(){}
	
	public ArrayList<Integer> GetHighlights(){
		return _highlights;
	}
	
	@Override
	public void startDocument() throws SAXException{
		_highlights = new ArrayList<Integer>();
	}
	
	@Override
	public void endDocument() throws SAXException{}
	
	@Override
	public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException{}
	
	@Override
	public void characters(char ch[], int start, int length){
		_current = new String(ch, start, length);
	}
	
	@Override
	public void endElement(String uri, String localName, String qName) throws SAXException{
		if(localName.equals("id")){
			_highlights.add(Integer.parseInt(_current));
		}
	}	
}
